package com.hotdog.controller;

import com.hotdog.pojo.Comment;
import com.hotdog.service.CommentService;
import com.hotdog.vo.PageResult;
import com.hotdog.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 评论Controller
 * 同于接收评论发送的请求
 *
 * @author 郭鲁政
 */
@PreAuthorize("hasAuthority('sys:res:list')")
@RestController
@RequestMapping("/view/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @GetMapping("/getCommentInfo")
    public PageResult getInfo(PageResult pageResult) {
        PageResult info = commentService.getInfo(pageResult);
        return info;
    }

    @PutMapping("/changestatus")
    public SysResult changestatus(@RequestBody Comment comment) {
        SysResult sysResult = commentService.changestatus(comment);
        return sysResult;
    }

    @PostMapping("/insertInfo")
    public SysResult insertInfo(@RequestBody Comment comment) {

        SysResult sysResult = commentService.insertInfo(comment);
        return sysResult;
    }
}
